Skip to content

Conversation

@lucasly-ba
Copy link
Contributor

@lucasly-ba lucasly-ba commented Nov 17, 2025

This PR implements unused mut lint, it uses the hir default visitor and visit IdentifierPattern and StructPatternFieldIdent, to add to a map of mutable vars in the lint unused context.

Requires #4285

@lucasly-ba lucasly-ba force-pushed the unused-mut branch 6 times, most recently from fac95ea to 85f2a83 Compare November 18, 2025 12:42
@lucasly-ba lucasly-ba force-pushed the unused-mut branch 3 times, most recently from 758101a to 79876a5 Compare December 18, 2025 16:00
gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::UnusedChecker):
	Add warning for identifier pattern and field ident pattern in struct
	(UnusedChecker::visit): Add methods.
	* checks/lints/unused/rust-unused-checker.h: Same here.
	* checks/lints/unused/rust-unused-collector.cc (UnusedCollector::UnusedCollector):
	Collect unused mut variables
	(UnusedCollector::visit): Add methods.
	* checks/lints/unused/rust-unused-collector.h: Same here.
	* checks/lints/unused/rust-unused-context.cc (UnusedContext::remove_assign):
	Add methods for unused mut set.
	(UnusedContext::add_mut): Same here.
	(UnusedContext::remove_mut): Same here.
	(UnusedContext::is_mut_used): Same here.
	* checks/lints/unused/rust-unused-context.h: Same here.

gcc/testsuite/ChangeLog:

	* rust/compile/unused-mut-identifier_0.rs: New test.
	* rust/compile/unused-mut-struct-field_0.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
@P-E-P P-E-P added this pull request to the merge queue Dec 19, 2025
Merged via the queue into Rust-GCC:master with commit 49002a8 Dec 19, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants